<?php
class Admin_Form_ValidatePageContent extends Zendvn_Validate_Form{

	public function __construct($arrParam = null, $options = null){
		
		define('NAME_ID',$arrParam['id']);
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'validates/page-content.ini'));
		if($arrParam['action']=='edit'){
			$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
					'fileConfig'=>'validates/page-content.ini',
					'section'=>'edit'));
		}
		//================================Validate Name================================
		$name  = $config->getConfig('name');
		$validator  =  $this->validate($name,$arrParam);
		if(!$validator->isValid($arrParam['name'])){
			$message = $validator->getMessages();
			$this->_arrError['name'] = current($message);
		}
		
		//================================Validate Name================================
		$name  = $config->getConfig('alias');
		$validator  =  $this->validate($name,$arrParam);
		if(!$validator->isValid($arrParam['alias'])){
			$message = $validator->getMessages();
			$this->_arrError['alias'] = current($message);
		}
		
		//================================Validate content================================
		$name  = $config->getConfig('content');
		$validator  =  $this->validate($name,$arrParam);
		if(!$validator->isValid($arrParam['content'])){
			$message = $validator->getMessages();
			$this->_arrError['content'] = current($message);
		}
	
		//================================Validate Html_descript================================
		if($arrParam['html_descript']){
			$name  = $config->getConfig('html_descript');
			$validator  =  $this->validate($name,$arrParam);
			if(!$validator->isValid($arrParam['html_descript'])){
				$message = $validator->getMessages();
				$this->_arrError['html_descript'] = current($message);
			}
		}
		//================================Validate html_keyword================================
		if($arrParam['html_keyword']){
			$name  = $config->getConfig('html_keyword');
			$validator  =  $this->validate($name,$arrParam);
			if(!$validator->isValid($arrParam['html_keyword'])){
				$message = $validator->getMessages();
				$this->_arrError['html_keyword'] = current($message);
			}
		}
		
		/*=======================================================
		 * Start - return correct data array
		 *=======================================================*/
		$this->_arrData = $arrParam;
	}
	
	public function getData(){
		return $this->_arrData;
	}
	//return true|false
	public function isVaild(){
		$flag = false;
		if(count($this->_arrError) > 0 && $this->_arrError != ''){
			$flag = true;
		}
		return $flag;
	}
	
	public function getMessageErrors(){
		return $this->_arrError;
	}
	
}







